<!-- 分类 -->
<template>
  <div class="classify">
    <!-- 头部 -->

    <div class="classify_header">
      <svg-icon iconClass="back" class="zhuo_back" @click="goHome()"></svg-icon>
      <div class="calssify_input">
        <svg-icon iconClass="fangdajing" class="text_fangdajing"></svg-icon>
        <input type="text" class="text_input" placeholder="苹果12" />
      </div>
      <span></span>
      <span></span>
    </div>
    <!-- 主体 -->
    <div class="classify_box">
      <!-- 左边 -->
      <div class="let_box" ref="letf_box">
        <div
          class="let_text"
          ref="letfs"
          v-for="(item, ind) in classify"
          :key="ind"
          :class="active === ind ? 'active' : 'let_text'"
          @click="tab_button(ind)"
        >
          {{ item.texts }}
        </div>
      </div>
      <!-- 右边 -->
      <div class="rig_box">
        <div class="rig_text">
          <div class="rig_head" v-for="(item, ind) in info" :key="ind">
            <b>{{ item.title }}</b>
            <div class="rigte_text">
              <dl v-for="(items, index) in item.info" :key="index">
                <dd><img :src="items.img" alt="" /></dd>
                <dt>{{ items.name }}</dt>
              </dl>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  //import引入的组件需要注入到对象中才能使用
  components: {},
  data() {
    //这里存放数据
    return {
      classify: [],
      active: 0,
      info: [],
    };
  },
  //监听属性 类似于data概念
  computed: {},
  //监控data中的数据变化
  watch: {},
  //方法集合
  methods: {
    // 返回首页
    goHome() {
      this.$router.push("/layout/home");
    },
    // tab切换
    tab_button(ind) {
      this.active = ind;
      this.info = this.classify[ind].icof;
      // let dom = this.$refs.letfs[ind];
      // let heade = dom.offsetTop - dom.clientHeight;
      // this.$refs.letf_box.scrollTop = heade;
      // this.$refs.letf_box.style = `transform: translateY(${heade})`;
      // this.$refs.letf_box.style = `transform: translateY(${heade})`;
      // this.$$refs.
    },
  },
  //生命周期 - 创建完成（可以访问当前this实例）
  created() {
    this.$api.classify().then((res) => {
      if (res.code === 200) {
        this.classify = res.data.classify;
        this.info = this.classify[0].icof;
      }
    });
  },
  //生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {},
};
</script>
<style lang="scss" scoped>
@import "../../assets/css/style.scss";

.classify {
  width: 100%;
  height: 100%;
  display: flex;
  overflow: hidden;
  flex-direction: column;
  .classify_header {
    width: 100%;
    height: px2rem(40);
    display: flex;
    justify-content: space-between;
    padding: 0 $padding;
    align-items: center;
    .zhuo_back {
      font-size: $iconSize;
    }
    .calssify_input {
      width: 70%;
      height: 70%;
      line-height: px2rem(20);
      border-radius: px2rem(20);
      background: #f6f6f6;
      display: flex;
      align-items: center;
      .text_input {
        width: 75%;
        height: 100%;
        background: #f6f6f6;
        border: none;
        font-size: px2rem(12);
      }
      .text_fangdajing {
        width: 20%;
        height: 70%;
        font-size: px2rem(12);
      }
    }
  }
  .classify_box {
    flex: 1;
    display: flex;
    justify-content: space-between;
    overflow: hidden;
    .let_box {
      width: px2rem(80);
      height: 100%;
      font-size: px2rem(14);
      overflow-y: auto;
      border-right: 1px solid #f7f7f7;
      // transition: all 0.2s ease 0s;
      transition: 0.8;
      .let_text {
        height: px2rem(40);
        width: 100%;
        line-height: px2rem(40);
        text-align: center;
        background: #f7f7f7;
        &.active {
          background: #fff;
          color: red;
        }
      }
    }

    .rig_box {
      flex: 1;
      font-size: px2rem(14);
      overflow-y: auto;
      .rig_title {
        width: 78.5vw;
        height: px2rem(40);
        display: flex;
        border: 1px solid #f7f7f7;
        align-items: center;
        justify-content: space-between;
        padding: 0 px2rem(5);
        position: absolute;
        background: #ffff;
        top: px2rem(40);
      }
      .rig_text {
        background: #fff;
        width: 100%;
        height: 100vh;
        overflow-y: auto;
        .rig_head {
          width: 100%;
          padding: 0 px2rem(5);
          .rigte_text {
            width: 100%;
            display: flex;
            padding: 0 px2rem(25);
            flex-wrap: wrap;
            dl {
              height: px2rem(100);
              width: 29%;
              margin: px2rem(5) px2rem(5);
              flex-shrink: 0;
              display: flex;
              justify-content: space-between;
              flex-direction: column;
              padding: px2rem(5);
              align-items: center;
              dd {
                width: 100%;
                height: 100%;
                img {
                  width: 100%;
                  height: 100%;
                }
              }
              dt {
                width: 100%;
                text-align: center;
                height: px2rem(12);
              }
            }
          }
        }
      }
    }
  }
}
</style>
